home *** CD-ROM | disk | FTP | other *** search
- Path: Rezonet.net!news
- From: ray@ultimate-tech.com (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: swap high and low 16 bits?
- Date: 20 Jan 1996 02:35:26 GMT
- Organization: Ultimate Technographics Inc.
- Message-ID: <4dpkde$h3n@ns.RezoNet.NET>
- References: <Pine.OSF.3.91.960115174921.19742A-100000@io.UWinnipeg.ca> <ALUN.CHAMPION.96Jan16110016@g7240065.bridge.bst.bls.com> <Pine.OSF.3.91.960117143539.1414A-100000@io.UWinnipeg.ca> <821927899snz@genesis.demon.co.uk>
- NNTP-Posting-Host: 204.19.230.7
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In referenced article, Lawrence Kirby says...
- >In article <Pine.OSF.3.91.960117143539.1414A-100000@io.UWinnipeg.ca>
- > wsimpson@uwinnipeg.ca "Bill Simpson" writes:
- >
- >>> The way I understand you is that you are using the result of time()
- >>> as your random number.
- >>No, as the seed to the RNG.
- >>
- >>If my program runs and terminates quickly, it will get almost exactly
- >>the same seed on successive runs (differing only by low bits).
- >>
- >>But not if I swap high and low 16 bits.
- >>
- >>I have done this now and it works nicely. The seeds are far apart,
- >>even for runs <1 minute apart.
- >
- >Just changing high order bits may not be a good idea since with some
- >RNGs this won't filter down to the lower order bits. I suggest you use
- >one of the expressions I posted earlier (which are incidentally
- >simpler than a full swap).
-
- Now that I see the original poster was in fact using time to seed the
- random number generator, I'm not quite sure what the problem is. The
- closesness of one seed to another seed in no way implies that the two
- random sequences so produced will be "close to" each other.
-
- A difference of only one in the value given to the seeding function
- causes a totally different sequences of numbers to be produced.
-
- --
- Ray Dunn (opinions are my own) | Phone: (514) 938 9050
- Montreal | Phax : (514) 938 5225
- ray@ultimate-tech.com | Home : (514) 630 3749
-
-